********************************************************************************
* appendix table 8: nn robustness

********************************************************************************

cd "$main_dir/data"
	
* no pioneer
use near_near_np, clear	

reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_iso_year building_id) vce(cl building_id)

capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1 & building_sample==1 & min_number>0

* the other columns use the same file
use near_near_m250_i250_g,clear

* low percent white

reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if building_pct_white<.5 & building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
gen sample=e(sample)

preserve
keep if sample==1 & building_sample==1 & min_number>0 
capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1
drop sample
restore

drop sample


***********************

* cut g cutoff
gen alt_g=0
replace alt_g = 1 if msa=="atlanta" & building_med_hh_inc<56000
replace alt_g = 1 if msa=="austin" & building_med_hh_inc<64000
replace alt_g = 1 if msa=="chicago" & building_med_hh_inc<59000
replace alt_g = 1 if msa=="denver" & building_med_hh_inc<67000
replace alt_g = 1 if msa=="la" & building_med_hh_inc<60000
replace alt_g = 1 if msa=="brooklyn" & building_med_hh_inc<66000
replace alt_g = 1 if msa=="philadelphia" & building_med_hh_inc<59000
replace alt_g = 1 if msa=="portland" & building_med_hh_inc<62000
replace alt_g = 1 if msa=="sf" & building_med_hh_inc<86000
replace alt_g = 1 if msa=="seattle" & building_med_hh_inc<73000
replace alt_g = 1 if msa=="dc" & building_med_hh_inc<73000

reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if alt_g==1 & building_sample==1 & min_number>0  ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)
gen sample=e(sample)

preserve
keep if sample==1 & building_sample==1 & min_number>0 
capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1
drop sample
restore

drop sample

***********************

* drop brooklyn
reghdfe lrent treated_after /// 
	i.listing_bedroom i.listing_bathroom ///
	if msa!="brooklyn" &  building_sample==1 & min_number>0 ///
	[aweight=building_sample_weight],absorb(msa_year building_id) vce(cl building_id)

gen sample=e(sample)

preserve
keep if sample==1 & building_sample==1 & min_number>0 
capture drop building_tag
egen building_tag=tag(building_id)
tab treated if building_tag==1
drop sample
restore


	
